#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2018/12/17 23:13
# @Author  : lizhen
# @Site    : 
# @File    : Hello.py
# @Software: PyCharm
from twisted.internet import endpoints, reactor
from twisted.web import resource, server


class HelloDemo(resource.Resource):
    isLeaf = True

    def render_GET(self, request):
        return b'<h1>hello!</h1>'


def _test_hello():
    """
    _test_hello()
    >
    192.168.1.103:8000
    """
    site = server.Site(HelloDemo())
    endpoint = endpoints.TCP4ServerEndpoint(reactor, port=8000, interface="0.0.0.0")
    endpoint.listen(site)
    reactor.run()


if __name__ == '__main__':
    _test_hello()
